package com.zhilianbao.leyaogo.view.me;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;


import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.constants.IntentConfig;
import com.zhilianbao.leyaogo.ui.fragment.base.BaseFragment;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * ClassName: SelectGenderFragment <br>
 * Description: 选择性别Fragment<br>
 * Author: Cyarie <br>
 * Created: 2016/8/12 17:17 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public class SelectGenderFragment extends BaseFragment {

    @BindView(R.id.ll_man)
    LinearLayout mLlMan;
    @BindView(R.id.ll_woman)
    LinearLayout mLlWoman;

    //    @BindView(R.id.iv_man)
    //    ImageView mIvMan;
    //    @BindView(R.id.iv_woman)
    //    ImageView mIvWoman;
    //    @BindView(R.id.iv_unknown)
    //    ImageView mIvUnknown;
    private String gender;

    public static SelectGenderFragment getInstance() {
        SelectGenderFragment selectGenderFragment = new SelectGenderFragment();
        return selectGenderFragment;
    }

    @Override
    protected void initToolbarHere() {
        initToolbarWithLeftText(getString(R.string.sex_title), getString(R.string.main_me));
    }

    @Override
    protected void initViewsAndEvents(Bundle savedInstanceState) {

        //        if ((com.bql.robotmanager.utils.Utils.getUserInfo() != null) {
        //            sex = com.bql.robotmanager.utils.Utils.getUserInfo().getSex();
        //            switch (sex) {
        //                //男
        //                case 0:
        //                    mIvMan.setImageResource(R.drawable.choice_tick);
        //                    mIvWoman.setImageDrawable(null);
        //                    mIvUnknown.setImageDrawable(null);
        //                    break;
        //                //女
        //                case 1:
        //                    mIvMan.setImageDrawable(null);
        //                    mIvWoman.setImageResource(R.drawable.choice_tick);
        //                    mIvUnknown.setImageDrawable(null);
        //                    break;
        //                //保密
        //                case 2:
        //                    mIvMan.setImageDrawable(null);
        //                    mIvWoman.setImageDrawable(null);
        //                    mIvUnknown.setImageResource(R.drawable.choice_tick);
        //                    break;
        //            }
        //        }
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.fragment_select_gender;
    }


    @OnClick({R.id.ll_man, R.id.ll_woman})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_man:
                //                mIvMan.setImageResource(R.drawable.choice_tick);
                //                mIvWoman.setImageDrawable(null);
                //                mIvUnknown.setImageDrawable(null);
                gender = "0";
                break;
            case R.id.ll_woman:
                //                mIvMan.setImageDrawable(null);
                //                mIvWoman.setImageResource(R.drawable.choice_tick);
                //                mIvUnknown.setImageDrawable(null);
                gender = "1";
                break;
        }
        setResult();

    }

    /**
     * 设置返回结果
     */
    private void setResult() {
        Bundle bundle = new Bundle();
        bundle.putString(IntentConfig.USER_EDIT_USER_INFO, gender);
        setFramgentResult(3, bundle);
        pop();
    }

    @Override
    public boolean isInjectSkinView() {
        return true;
    }
}
